<template>
  <el-table :data="tableData" size="mini">
    <el-table-column prop="stageId" label="阶段" align="center" />
    <el-table-column prop="setTemperature" label="设定温度" align="center">
      <template slot-scope="scope">
        <div>
          <span>{{ scope.row.setTemperature }}℃ </span>
        </div>
      </template>
    </el-table-column>
    <el-table-column prop="startTime" label="开始时间" align="center">
      <template slot-scope="scope">
        {{ scope.row.startTime | formatDate }}
      </template>
    </el-table-column>
    <el-table-column prop="endTime" label="结束时间" align="center">
      <template slot-scope="scope">
        {{ scope.row.endTime | formatDate }}
      </template></el-table-column
    >
    <el-table-column prop="endTime" label="实际温度范围" align="center">
      <template slot-scope="scope">
        <span
          v-if="
            scope.$index > 0 &&
              scope.row.setTemperature ===
                tableData[scope.$index - 1].setTemperature
          "
        >
          {{ Number(scope.row.setTemperature) - 2 }}℃ -
          {{ Number(scope.row.setTemperature) + 2 }}℃
        </span>
        <span v-else
          >{{ scope.row.startTemperature }}℃ -
          {{ scope.row.endTemperature }}℃</span
        >
      </template></el-table-column
    >
    <el-table-column label="工艺温度要求" align="center">
      <template slot-scope="scope">
        <div v-if="scope.row['温度上限(℃)'] || scope.row['温度下限(℃)']">
          {{ scope.row["温度上限(℃)"] || "--" }}℃ ~
          {{ scope.row["温度下限(℃)"] || "--" }}℃
        </div>
        <div v-else>
          <span
            v-if="
              scope.$index > 0 &&
                scope.row.setTemperature ===
                  tableData[scope.$index - 1].setTemperature
            "
          >
            {{ Number(scope.row.setTemperature) - 10 }}℃ -
            {{ Number(scope.row.setTemperature) + 10 }}℃
          </span>
          <span v-else>--</span>
        </div>
      </template>
    </el-table-column>
    <el-table-column label="实际升温速度" align="center">
      <!-- <template slot-scope="scope">
       
      </template> -->
    </el-table-column>
    <el-table-column label="工艺升温速度要求" align="center">
      <template slot-scope="scope">
        <div>
          {{ scope.row["升温速度上限(℃/min)"] || "--" }} ~
          {{ scope.row["升温速度下限(℃/min)"] || "--" }}℃/min
        </div>
      </template>
    </el-table-column>
    <el-table-column label="实际保温时间" align="center">
      <template slot-scope="scope">
        {{ faultDate(scope.row.startTime, scope.row.endTime) }}
      </template>
    </el-table-column>
    <el-table-column label="工艺保温时间要求" align="center">
      <template slot-scope="scope">
        <div
          v-if="
            scope.row['保温时间下限(min)'] || scope.row['保温时间上限(min)']
          "
        >
          {{ scope.row["保温时间下限(min)"] || "--" }} ~
          {{ scope.row["保温时间上限(min)"] || "--" }}min
        </div>
        <div v-else>--</div>
      </template>
    </el-table-column>
    <el-table-column label="是否合格" align="center">
      <!-- eslint-disable-next-line -->
      <template slot-scope="scope">
        <el-tag type="success">检验合格</el-tag>
      </template>
    </el-table-column>

    <!-- <el-table-column prop="startTemperature" label="开始温度" align="center">
      <template slot-scope="scope">
        {{ scope.row.startTemperature }}℃
      </template>
    </el-table-column>

    <el-table-column prop="endTemperature" label="结束温度" align="center">
      <template slot-scope="scope"> {{ scope.row.endTemperature }}℃ </template>
    </el-table-column>
    <el-table-column prop="col" label="运行时间" align="center">
      <template slot-scope="scope">
        {{ faultDate(scope.row.startTime, scope.row.endTime) }}
      </template>
    </el-table-column> -->
  </el-table>
</template>

<script>
import { timeDifference } from "@/utils/currentDate";
export default {
  props: {
    tableData: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    faultDate() {
      return function(faultDate, completeTime) {
        return timeDifference(completeTime, faultDate);
      };
    }
  }
};
</script>

<style>
/* ::v-deep .el-table {
  margin-top: 10px;
  table {
    width: 100% !important;
  }
  .el-table__body,
  .el-table__header {
    width: 100% !important;
  }

  .el-table__body {
    width: 100% !important;
  }
} */
</style>
